package com.woniu.cinema.service.impl;

import java.util.List;

import com.woniu.cinema.dto.DynamicCinemaRequest;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.woniu.cinema.mapper.CinemaMapper;
import com.woniu.cinema.domain.Cinema;
import com.woniu.cinema.service.CinemaService;

/**
 * 电影院信息Service业务层处理
 *
 * @author yy
 * @date 2023-09-27
 */
@Service
public class CinemaServiceImpl implements CinemaService
{
    @Autowired
    private CinemaMapper cinemaMapper;

    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 查询电影院信息
     *
     * @param cinemaId 电影院信息ID
     * @return 电影院信息
     */
    @Override
    public Cinema selectCinemaById(Integer cinemaId)
    {
        return cinemaMapper.selectCinemaById(cinemaId);
    }

    /**
     * 查询电影院信息列表
     *
     * @param cinema 电影院信息
     * @return 电影院信息
     */
    @Override
    public List<Cinema> selectCinemaList(Cinema cinema)
    {
        return cinemaMapper.selectCinemaList(cinema);
    }

    /**
     * 新增电影院信息
     *
     * @param cinema 电影院信息
     * @return 结果
     */
    @Override
    public int insertCinema(Cinema cinema)
    {
        return cinemaMapper.insertCinema(cinema);
    }

    /**
     * 修改电影院信息
     *
     * @param cinema 电影院信息
     * @return 结果
     */
    @Override
    public int updateCinema(Cinema cinema)
    {
         cinemaMapper.updateCinema(cinema);

        rabbitTemplate.convertAndSend("search_cinema_exchange", "search_cinema_routingkey", cinema.getCinemaId());

        return 1;
    }

    /**
     * 批量删除电影院信息
     *
     * @param cinemaIds 需要删除的电影院信息ID
     * @return 结果
     */
    @Override
    public int deleteCinemaByIds(Integer[] cinemaIds)
    {
        return cinemaMapper.deleteCinemaByIds(cinemaIds);
    }

    /**
     * 删除电影院信息信息
     *
     * @param cinemaId 电影院信息ID
     * @return 结果
     */
    @Override
    public int deleteCinemaById(Integer cinemaId)
    {
        return cinemaMapper.deleteCinemaById(cinemaId);
    }

    @Override
    public List<Cinema> dynamiclist(DynamicCinemaRequest request) {


        return cinemaMapper.dynamiclist(request);
    }

    @Override
    public List<Cinema> queryCinemaByCinemaId(Integer cinemaId) {


        return cinemaMapper.queryCinemaByCinemaId(cinemaId);

    }
}
